﻿using System;
using System.Collections.Generic;
using System.Text;
using SqlSugar;

namespace Slwy.Data.Entity.SqlSugarExtensions
{
    public class SlwyUpdateableProvider<T> : UpdateableProvider<T> where T : class, new()
    {
        public IUpdateable<T> Table(string tableName)
        {
            var entityName = typeof(T).Name;
            IsAs = true;
            OldMappingTableList = this.Context.MappingTables;
            this.Context.MappingTables = this.Context.Utilities.TranslateCopy(this.Context.MappingTables);
            this.Context.MappingTables.Remove(this.Context.MappingTables.Find(m => m.EntityName == entityName));
            this.Context.MappingTables.Add(entityName, tableName);
            return this; ;
        }

        public virtual IUpdateable<T> Updateable<T>(T[] UpdateObjs) where T : class, new()
        {
            base.Context.Updateable<T>()
        }
    }

    public interface ISlwyUpdateable<T> : IUpdateable<T> where T : class, new()
    {
        ISlwyUpdateable<T> Table(string tableName);
    }
}
